<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<style>

    #bootstrap-table tr:nth-child(even) {
        background: transparent !important;
    }

    #bootstrap-table th {
        background: transparent !important;
    }

    #bootstrap-table a {
        width: 100%;
        height: 100%;
        display: block;
        color: #000000;
    }

    #bootstrap-table a:hover {
        color: #000000;
    }

    #bootstrap-table a:visited {
        color: #000000;
    }

    #bootstrap-table a:active {
        color: #000000;
    }
</style>
<body class="hold-transition skin-yellow sidebar-mini">
<section class="content-header">
    <h1>生产进度看板</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" class="form-horizontal">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        项目编号
                                    </label>
                                    <label class="control-label">
                                        <input name="prodNo" class="form-control" type="text" maxlength="255"
                                               value=""
                                               placeholder="请输入项目编号"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        项目名称
                                    </label>
                                    <label class="control-label">
                                        <input name="proNam" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入项目名称"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        项目数量
                                    </label>
                                    <label class="control-label">
                                        <input name="prodNum" class="form-control" type="text" maxlength="255"
                                               oninput="value=value.replace(/^(0+)|[^\d]+/g,'')"
                                               placeholder="请输入项目数量"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        安装地点
                                    </label>
                                    <label class="control-label">
                                        <input name="insSit" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入安装地点"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        需方
                                    </label>
                                    <label class="control-label">
                                        <input name="cus" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入需方"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        分类
                                    </label>
                                    <label class="control-label">
                                        <select name="prodTyp" class="form-control">
                                            <option value="">全部</option>
                                            <option value="1">设备类</option>
                                            <option value="2">其他类</option>
                                        </select>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        任务类别
                                    </label>
                                    <label class="control-label">
                                        <select name="taskType" class="form-control">
                                            <option value="all">全部</option>
                                            <option  selected="selected" value="production">生产</option>
                                            <option value="design">设计</option>
                                            <option value="technology">工艺</option>
                                            <option value="cut">下料</option>
                                            <option value="assemble">装配</option>
                                            <option value="deliverGoods">发货</option>
                                            <option value="install">安装</option>
                                            <option value="debug">调试</option>
                                        </select>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        任务状态
                                    </label>
                                    <label class="control-label">
                                        <select name="taskStatus" class="form-control selectpicker" data-actions-box="true" multiple>
                                            <!--<option style="width: 197px" value="0">不需要</option>-->
                                            <option style="width: 197px" selected="selected"  value="1">未开始</option>
                                            <option style="width: 197px" selected="selected"  value="2">执行中</option>
                                            <option style="width: 197px" value="3">已完成</option>
                                        </select>
                                        <input name="taskStatusStr" value="1,2" type="hidden" style="display: none">
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        项目状态
                                    </label>
                                    <label class="control-label">
                                        <select name="proCancelMark" class="form-control">
                                            <option value="">全部</option>
                                            <option value="0" selected="selected">正常</option>
                                            <option value="1">取消</option>
                                        </select>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        生产令状态
                                    </label>
                                    <label class="control-label">
                                        <select name="prodManSta" class="form-control">
                                            <option value="">全部</option>
                                            <option value="1" selected="selected">正常</option>
<!--                                            <option value="2">终止</option>-->
                                            <option value="3">暂缓</option>
                                        </select>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">交货时间</label>
                                    <label class="control-label">
                                        <input type="text" class="form-control datepicker" name="startTime"
                                               readonly="readonly"/>
                                        <span> 至 </span>
                                        <input type="text" class="form-control datepicker" name="endTime"
                                               readonly="readonly"/></label>
                                </div>
                                <button id="btn-search" type="button" class="btn btn-success">
                                    搜索
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div content="toolBar" class="row">
                    <button onclick="exportBySearch(this)" shiro:hasPermission="pro:proProgress:export" class="btn btn-info">全部导出</button>
                    <img th:src="@{/img/downloadding.gif}" id="btn_tips" style="display: none"/>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    let table;
    $(function () {
        $("#queryForm [name='taskStatus']").change(function (){
            $("#queryForm [name='taskStatusStr']").val($("#queryForm [name='taskStatus']").val());
        });

        /**
         * 加载列表
         */
        table = js.table.init({
            url: ctx + "task/prodOrdQuery/list",
            showColumns: true,
            showExport: true,
            rowStyle:function (row, index){
                if (row.proCancelMark === 1) {
                    return {css: {"padding": "0", "background": "#C90302", "color": "#FFDBA7"}}
                } else if (row.prodManSta === 2) {
                    return {css: {"padding": "0", "background": "#C90302", "color": "#FFDBA7"}}
                } else if (row.prodManSta === 3) {
                    return {css: {"padding": "0", "background": "#F9C7CB", "color": "#4E4E4E"}}
                }else {
                    return {css: {"background": "#FFFFFF"}}
                }
            },
            columns: [
                {
                    title: '序号', field: 'orderNo', width: '60',
                    formatter: function (value, row, index, field) {
                        var pageSize = table.bootstrapTable('getOptions').pageSize;
                        var pageNumber = table.bootstrapTable('getOptions').pageNumber;
                        return pageSize * (pageNumber - 1) + index + 1;
                    }
                },
                {
                    title: '项目编号', field: 'prodNo', width: '65',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '项目名称', field: 'proNam',width:'30',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '数量', field: 'prodNum',width: '60',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '安装地点', field: 'insSit',width:'100',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '需方', field: 'cus',width:'250',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '交货时间', field: 'prodDelDat', width: '10'
                },
                {
                    title: '是否<br>重点', field: "prodIsKey",width: '50',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            if (parseInt(value) === 1) {
                                return '是';
                            } else {
                                return '否';
                            }
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '分类', field: "prodTyp", width: '60',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            if (parseInt(value) === 1) {
                                return '设备类';
                            } else if (parseInt(value) === 2) {
                                return '其他';
                            }
                        } else {
                            return '--';
                        }
                    }
                },
                // {
                //     title: '生产令状态', field: "prodManSta", width: '60',
                //     formatter: function (value, row, index) {
                //         if (value != null) {
                //             if (value === 1) {
                //                 return '<label class="badge label-success">正常</label>';
                //             } else if (value === 2) {
                //                 return '<label class="badge label-danger">终止</label>';
                //             }else if (value === 3) {
                //                 return '<label class="badge label-warning">暂缓</label>';
                //             }
                //         } else {
                //             return '--';
                //         }
                //     }
                // },
                {
                    title: '设计', field: "dsnSta", width: '60',
                    formatter: function (value, row, index) {
                        if (value === 0) {
                            return '<label class="badge label-info">不需要</label>';
                        } else if (value === 1 || value === null) {
                            return '<label class="badge label-default">未开始</label>';
                        } else if (value === 2) {
                            return '<label class="badge label-warning">执行中</label>';
                        } else if (value === 3) {
                            return '<label class="badge label-success">已完成</label>';
                        }
                    }
                },
                {
                    title: '工艺', field: "tecSta", width: '60',
                    formatter: function (value, row, index) {
                        if (value === 0) {
                            return '<label class="badge label-info">不需要</label>';
                        } else if (value === 1 || value === null) {
                            return '<label class="badge label-default">未开始</label>';
                        } else if (value === 2) {
                            return '<label class="badge label-warning">执行中</label>';
                        } else if (value === 3) {
                            return '<label class="badge label-success">已完成</label>';
                        }
                    }
                },
                {
                    title: '下料', field: "cutSta", width: '60',
                    formatter: function (value, row, index) {
                        if (value === 0) {
                            return '<label class="badge label-info">不需要</label>';
                        } else if (value === 1 || value === null) {
                            return '<label class="badge label-default">未开始</label>';
                        } else if (value === 2) {
                            return '<label class="badge label-warning">执行中</label>';
                        } else if (value === 3) {
                            return '<label class="badge label-success">已完成</label>';
                        }
                    }
                },
                {
                    title: '生产', field: "prodSta", width: '60',
                    formatter: function (value, row, index) {
                        if (value === 0) {
                            return '<label class="badge label-info">不需要</label>';
                        } else if (value === 1 || value === null) {
                            return '<label class="badge label-default">未开始</label>';
                        } else if (value === 2) {
                            return '<label class="badge label-warning">执行中</label>';
                        } else if (value === 3) {
                            return '<label class="badge label-success">已完成</label>';
                        }
                    }
                },
                {
                    title: '装配', field: "assSta", width: '60',
                    formatter: function (value, row, index) {
                        if (value === 0) {
                            return '<label class="badge label-info">不需要</label>';
                        } else if (value === 1 || value === null) {
                            return '<label class="badge label-default">未开始</label>';
                        } else if (value === 2) {
                            return '<label class="badge label-warning">执行中</label>';
                        } else if (value === 3) {
                            return '<label class="badge label-success">已完成</label>';
                        }
                    }
                },
                {
                    title: '发货', field: "delSta", width: '60',
                    formatter: function (value, row, index) {
                        if (value === 0) {
                            return '<label class="badge label-info">不需要</label>';
                        } else if (value === 1 || value === null) {
                            return '<label class="badge label-default">未开始</label>';
                        } else if (value === 2) {
                            return '<label class="badge label-warning">执行中</label>';
                        } else if (value === 3) {
                            return '<label class="badge label-success">已完成</label>';
                        }
                    }
                },
                {
                    title: '安装', field: "insSta", width: '60',
                    formatter: function (value, row, index) {
                        if (value === 0) {
                            return '<label class="badge label-info">不需要</label>';
                        } else if (value === 1 || value === null) {
                            return '<label class="badge label-default">未开始</label>';
                        } else if (value === 2) {
                            return '<label class="badge label-warning">执行中</label>';
                        } else if (value === 3) {
                            return '<label class="badge label-success">已完成</label>';
                        }
                    }
                },
                {
                    title: '调试', field: "debSta", width: '60',
                    formatter: function (value, row, index) {
                        if (value === 0) {
                            return '<label class="badge label-info">不需要</label>';
                        } else if (value === 1 || value === null) {
                            return '<label class="badge label-default">未开始</label>';
                        } else if (value === 2) {
                            return '<label class="badge label-warning">执行中</label>';
                        } else if (value === 3) {
                            return '<label class="badge label-success">已完成</label>';
                        }
                    }
                },
                {
                    title: '操作', width: '60',
                    formatter: function (value, row, index) {
                        let elements = new Array();
                        if (row.prodTyp === 1 && hasP('pro:single:view')) {
                            elements.push('<button class="btn btn-info btn-xs" onclick="viewInfoDev(\'' + row.prodNo + '\')">查看</button>');
                        } else if (row.prodTyp === 2 && hasP('pro:single:view')) {
                            elements.push('<button class="btn btn-info btn-xs" onclick="viewInfoOther(\'' + row.prodId + '\')">查看</button>');
                        }
                        return elements.join('');
                    }
                }
            ]
        });
        /**
         * 表格搜索
         */
        $("#btn-search").click(function () {
            js.table.search(table);
        });
    });


    /**
     * 设备类查看项目
     */
    function viewInfoDev(prodNo) {
        // window.open(ctx + 'task/prodOrdQuery/single/' + prodNo);
        js.post({
            url: ctx + "task/prodOrdQuery/singleCheckIsHaveDetail",
            data: {
                prodNo:prodNo
            },
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    window.open(ctx + 'task/prodOrdQuery/single/' + prodNo);
                } else {
                    js.modal.warning("尊敬的用户，该计划还没有排产，请您对该计划进行排产，排产后才可以查看！");
                }
            }
        });
    }

    /**
     * 其他类查看项目
     */
    function viewInfoOther(prodId) {
        window.open(ctx + 'task/scheduling/other/' + prodId+"/other");
    }

    /**
     * 重新加载
     */
    function reLoad() {
        js.table.refresh(table);
    }

    /**
     * 根据搜索条件导出Excel
     */
    function exportBySearch(obj){
        $(obj).hide();
        $("#btn_tips").show();
        $("#queryForm").attr("action","/task/prodOrdQuery/exportExcelBySearch");
        $("#queryForm").submit();
        setTimeout(function () {
            $("#queryForm").removeAttr("action");
            $("#btn_tips").hide();
            $(obj).show()
        }, 3000);
    }
</script>
</body>
</html>